﻿//-----------------------------------------------------------------------
// <copyright file="IssueEqualityComparer.cs">
//     Copyright (c) Nicole Calinoiu. All rights reserved.
// </copyright>
//-----------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;

namespace Bordecal.FxCop.Sdk.Testing
{
	[SuppressMessage("Microsoft.StyleCop.CSharp.DocumentationRules", "SA1600:ElementsMustBeDocumented",
				Justification = "False positive.")]
	internal sealed class IssueEqualityComparer : IEqualityComparer<Issue>
	{
		#region Fields

		private static IssueEqualityComparer _default = new IssueEqualityComparer();

		#endregion

		#region Constructors

		private IssueEqualityComparer()
		{
		}

		#endregion

		#region Properties

		internal static IEqualityComparer<Issue> Default
		{
			get
			{
				return IssueEqualityComparer._default;
			}
		}

		#endregion

		#region IEqualityComparer<Issue> Members

		public bool Equals(Issue x, Issue y)
		{
			bool result = false;

			if ((x == null) && (y == null))
			{
				result = true;
			}
			else if ((x != null) && (y != null))
			{
				result = x.Equals(y);
			}

			return result;
		}

		public int GetHashCode(Issue obj)
		{
			int result = 0;
			if (obj != null)
			{
				if (obj.File != null)
				{
					result = obj.File.GetHashCode();
				}

				if (obj.Line != null)
				{
					result |= obj.Line.GetHashCode();
				}
			}

			return result;
		}

		#endregion
	}
}